package com.insight.exceptions;

import com.insight.utils.CommonResult;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;

/**
 * @author yinyin
 * @date 2025/8/1 下午5:58
 */
@Provider
public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundException> {

    @Override
    public Response toResponse(NotFoundException exception) {
        CommonResult<Void> result = new CommonResult<>();
        result.setCode(404);
        result.setMsg("请求的资源不存在");

        return Response.status(Response.Status.OK) // 使用200状态码，通过业务码表示错误
                .entity(result)
                .build();
    }
}
